﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DailyComics.Common.Model.CachingStrategies;

namespace DailyComics.Common.Utilities.CachingStrategiesFactory
{
  public class MemoryAndFileCacheStrategy : ICachingStrategyFactory
  {
    private string path;
    private int size;

    public MemoryAndFileCacheStrategy()
      :this("default", 0)
    {

    }

    public MemoryAndFileCacheStrategy(string path)
      :this(path, 0)
    { }

    public MemoryAndFileCacheStrategy(string path, int size)
    {
      this.path = path;
      this.size = size;
    }

    #region ICachingStrategyFactory Members

    public Model.CachingStrategies.ICachingStrategy Create()
    {
      var strategy = new CompositeCacheStrategy();
      strategy.AddCache(new MemoryCacheStrategy(10));
      strategy.AddCache(new FileCacheStrategy(path));

      return strategy;
    }

    #endregion
  }
}
